<template>
  <div class="shopCategory">
    <div class="header_">
      <van-search v-model="value" show-action placeholder="请输入搜索关键词" @search="onSearch">
        <template #left>
          <!-- vue实例外创建 -->
          <van-icon name="arrow-left" />
        </template>
        <template #action>
          <div @click="onSearch">搜索</div>
        </template>
      </van-search>
    </div>
    <div class="menu">
      <van-dropdown-menu>
        <van-dropdown-item v-model="value1" :options="option1" />
        <van-dropdown-item v-model="value2" :options="option2" />
      </van-dropdown-menu>
    </div>
    <div class="shopCate_">
      <van-card
        v-for="goodslist in goods"
        :key="goodslist.proid"
        :price="goodslist.originprice"
        :desc="goodslist.proname"
        :title="goodslist.desc"
        :thumb="goodslist.img1"
        @click="gogoodsdetail(goodslist.proid)"
      />
    
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "shopCategory",
  data() {
    return {
      value: "",
      goods: [],

      //下拉菜单
      value1: 0,
      value2: "a",
      option1: [
        { text: "全部商品", value: 0 },
        { text: "价格升序", value: 1 },
        { text: "价格降序", value: 2 }
      ],
      option2: [
        { text: "默认排序", value: "a" },
        { text: "好评排序", value: "b" },
        { text: "销量排序", value: "c" }
      ]
    };
  },
  created() {
    let brand = this.$route.query.brand;
    let category = this.$route.query.category;
    this.value = brand
    console.log(brand, category);
    axios({
      url: "http://121.89.205.189:3001/api/pro/categorybrandprolist",
      params: {
        category: category,
        brand: brand
      }
    }).then(res => {
      if (res.data.code == 200) {
        this.goods = res.data.data;
        // console.log(this.goods);
      }
      console.log(this.goods);
    });
  },
  methods: {
    onSearch(val) {
      Toast(val);
    },
    onCancel() {
      Toast("取消");
    },
    gogoodsdetail(goodsid){
        this.$router.push("/goodsdetail/"+goodsid)
    }
  }
};
</script>

<style>
</style>